package com.xzx.springbootredis.service.impl;

import com.xzx.springbootredis.entity.Goods;
import com.xzx.springbootredis.repository.GoodsRepository;
import com.xzx.springbootredis.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class GoodsServiceImpl implements GoodsService {
    @Autowired
    private GoodsRepository goodsRepository;
    @Override
    public int save(Goods goods) {
        return goodsRepository.save(goods).getId();
    }

    @Override
    public Goods findByTitle(String title) {
        return goodsRepository.findByTitle(title);
    }

    @Override
    public Optional<Goods> findById(int id) {
        return goodsRepository.findById(id);
    }

}
